import React, { Component } from "react";
import PropTypes from "prop-types";
import { Icon } from '@ali/ding-ui';

export default class Breadcrumb extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        const breadcrumb = this.props.breadcrumb ? this.props.breadcrumb : [];
        const list = breadcrumb.map((item, index) => {
            return (
                <span key={index} 
                    onClick={() => {
                        window._rlog(`_weekly_breadcrub`)
                        this.props.handleBreadcrumb(item.deptId, index)
                    }} 
                    className="crumb" 
                >
                    {item.deptName && <span>{item.deptName}</span>}
                    {
                        (breadcrumb.length > 1 && index !== breadcrumb.length - 1) &&
                        <Icon type="right" size={28} />
                    }
                </span>
            )
        })
        return (
            <div className="breadcrumb">
                {list}
            </div>
        );
    }
}
Breadcrumb.propTypes = {
    breadcrumb: PropTypes.array,
};
